<template>
  <BasicModal :visible="visible" :width="850" @cancel="closeDetail" @ok="handleOk" title="cron配置">
    <section class="card-container">
      <a-tabs type="card" v-model:activeKey="activeKey">
        <a-tab-pane key="1" tab="秒">
          <a-radio-group v-model:value="result.second.cronEvery" @change="handleChange">
            <a-row>
              <a-radio value="1">每秒，允许的通配符[, - * /]</a-radio>
            </a-row>
            <a-row>
              <a-radio value="4">
                周期从<a-input-number :max="59" :min="0" size="small" v-model:value="result.second.rangeStart" />到
                <a-input-number :max="59" :min="0" size="small" v-model:value="result.second.rangeEnd" />秒
              </a-radio>
            </a-row>
            <a-row>
              <a-radio value="2">
                从<a-input-number :max="59" :min="0" size="small" v-model:value="result.second.incrementStart" />秒开始，每隔
                <a-input-number :max="59" :min="0" size="small" v-model:value="result.second.incrementIncrement" />秒执行
              </a-radio>
            </a-row>
            <a-row>
              <a-radio value="3">具体秒数(可多选)</a-radio>
              <a-select mode="multiple" size="small" style="width: 354px" v-model:value="result.second.specificSpecific">
                <a-select-option :key="index" :value="index" v-for="(val, index) in 60">{{ index }}</a-select-option>
              </a-select>
            </a-row>
          </a-radio-group>
        </a-tab-pane>
        <a-tab-pane key="2" tab="分钟">
          <a-radio-group v-model:value="result.minute.cronEvery" @change="handleChange">
            <a-row>
              <a-radio value="1">每分钟， 允许的通配符[, - * /]</a-radio>
            </a-row>
            <a-row>
              <a-radio value="4">
                周期从<a-input-number :max="60" :min="1" size="small" v-model:value="result.minute.rangeStart" />到
                <a-input-number :max="59" :min="0" size="small" v-model:value="result.minute.rangeEnd" />分
              </a-radio>
            </a-row>
            <a-row>
              <a-radio value="2">
                从<a-input-number :max="59" :min="0" size="small" v-model:value="result.minute.incrementStart" />分开始，每隔
                <a-input-number :max="59" :min="0" size="small" v-model:value="result.minute.incrementIncrement" />分执行
              </a-radio>
            </a-row>
            <a-row>
              <a-radio value="3">具体分钟数(可多选)</a-radio>
              <a-select mode="multiple" size="small" style="width: 340px" v-model:value="result.minute.specificSpecific">
                <a-select-option :key="index" :value="index" v-for="(val, index) in Array(60)">{{ index }}</a-select-option>
              </a-select>
            </a-row>
          </a-radio-group>
        </a-tab-pane>
        <a-tab-pane key="3" tab="小时">
          <a-radio-group v-model:value="result.hour.cronEvery" @change="handleChange">
            <a-row>
              <a-radio value="1">每小时，允许的通配符[, - * /]</a-radio>
            </a-row>
            <a-row>
              <a-radio value="4">
                周期从<a-input-number :max="59" :min="0" size="small" v-model:value="result.hour.rangeStart" />到
                <a-input-number :max="59" :min="0" size="small" v-model:value="result.hour.rangeEnd" />小时
              </a-radio>
            </a-row>
            <a-row>
              <a-radio value="2">
                从<a-input-number :max="59" :min="0" size="small" v-model:value="result.hour.incrementStart" />小时开始，每隔
                <a-input-number :max="59" :min="0" size="small" v-model:value="result.hour.incrementIncrement" />小时执行
              </a-radio>
            </a-row>
            <a-row>
              <a-radio value="3">具体小时数(可多选)</a-radio>
              <a-select mode="multiple" size="small" v-model:value="result.hour.specificSpecific" style="width: 354px">
                <a-select-option :key="index" :value="index" v-for="(val, index) in 24">{{ index }}</a-select-option>
              </a-select>
            </a-row>
          </a-radio-group>
        </a-tab-pane>
        <a-tab-pane key="4" tab="日">
          <a-radio-group v-model:value="result.day.cronEvery" @change="handleChange">
            <a-row>
              <a-radio value="1">每日，允许的通配符[, - * / L W]</a-radio>
            </a-row>
            <a-row>
              <a-radio value="2">不指定</a-radio>
            </a-row>
            <a-row>
              <a-radio value="4">
                周期从<a-input-number :max="59" :min="0" size="small" v-model:value="result.day.rangeStart" />到
                <a-input-number :max="59" :min="0" size="small" v-model:value="result.day.rangeEnd" />日
              </a-radio>
            </a-row>
            <a-row>
              <a-radio value="3">
                从<a-input-number :max="59" :min="0" size="small" v-model:value="result.day.incrementStart" />日开始，每隔
                <a-input-number :max="59" :min="0" size="small" v-model:value="result.day.incrementIncrement" />天执行
              </a-radio>
            </a-row>
            <a-row>
              <a-radio value="7">
                每月<a-input-number :max="31" :min="1" size="small" v-model:value="result.day.cronDaysNearestWeekday" />号最近的那个工作日
              </a-radio>
            </a-row>
            <a-row>
              <a-radio value="6">每月最后一天</a-radio>
            </a-row>
            <a-row>
              <a-radio value="5">具体天数(可多选)</a-radio>
              <a-select mode="multiple" size="small" v-model:value="result.day.specificSpecific" style="width: 354px">
                <a-select-option :key="index" :value="index + 1" v-for="(val, index) in 31">{{ index + 1 }}</a-select-option>
              </a-select>
            </a-row>
          </a-radio-group>
        </a-tab-pane>
        <a-tab-pane key="5" tab="月">
          <a-radio-group v-model:value="result.month.cronEvery" @change="handleChange">
            <a-row>
              <a-radio value="1">每月， 允许的通配符[, - * /]</a-radio>
            </a-row>
            <a-row>
              <a-radio value="5">不指定</a-radio>
            </a-row>
            <a-row>
              <a-radio value="4">
                周期从<a-input-number :max="60" :min="1" size="small" v-model:value="result.month.rangeStart" />到
                <a-input-number :max="59" :min="0" size="small" v-model:value="result.month.rangeEnd" />月
              </a-radio>
            </a-row>
            <a-row>
              <a-radio value="2">
                从<a-input-number :max="59" :min="0" size="small" v-model:value="result.month.incrementStart" />日开始，每隔
                <a-input-number :max="59" :min="0" size="small" v-model:value="result.month.incrementIncrement" />月执行
              </a-radio>
            </a-row>
            <a-row>
              <a-radio value="3">具体月数(可多选)</a-radio>
              <a-select mode="multiple" size="small" style="width: 340px" v-model:value="result.month.specificSpecific">
                <a-select-option :key="index" :value="index + 1" v-for="(val, index) in Array(12)">{{ index + 1 }}</a-select-option>
              </a-select>
            </a-row>
          </a-radio-group>
        </a-tab-pane>
        <a-tab-pane key="6" tab="周">
          <a-radio-group v-model:value="result.week.cronEvery" @change="handleChange">
            <a-row>
              <a-radio value="1">每周， 允许的通配符[, - * / L #]</a-radio>
            </a-row>
            <a-row>
              <a-radio value="5">不指定</a-radio>
            </a-row>
            <a-row>
              <a-radio value="2">
                周期从星期<a-input-number :max="60" :min="1" size="small" v-model:value="result.week.rangeStart" />到
                <a-input-number :max="59" :min="0" size="small" v-model:value="result.week.rangeEnd" />
              </a-radio>
            </a-row>
            <a-row>
              <a-radio value="3">
                第<a-input-number :max="59" :min="0" size="small" v-model:value="result.week.incrementStart" />周的星期
                <a-input-number :max="59" :min="0" size="small" v-model:value="result.week.incrementIncrement" />
              </a-radio>
            </a-row>
            <a-row>
              <a-radio value="6">
                本月最后一个星期
                <a-input-number :max="59" :min="0" size="small" v-model:value="result.week.lastweekDy" />
              </a-radio>
            </a-row>
            <a-row>
              <a-radio value="4">具体天(可多选)</a-radio>
              <a-select mode="multiple" size="small" style="width: 340px" v-model:value="result.week.specificSpecific">
                <a-select-option :key="index" :value="index + 1" v-for="(val, index) in Array(7)">{{ index + 1 }}</a-select-option>
              </a-select>
            </a-row>
          </a-radio-group>
        </a-tab-pane>
        <a-tab-pane key="7" tab="年">
          <a-radio-group v-model:value="result.year.cronEvery" @change="handleChange">
            <a-row>
              <a-radio value="5">不指定， 允许的通配符[, - * /] 非必填</a-radio>
            </a-row>
            <a-row>
              <a-radio value="1">每年</a-radio>
            </a-row>
            <a-row>
              <a-radio value="4">
                周期从<a-input-number :max="2119" :min="2013" size="small" v-model:value="result.year.rangeStart" />到
                <a-input-number :max="2119" :min="2013" size="small" v-model:value="result.year.rangeEnd" />
              </a-radio>
            </a-row>
          </a-radio-group>
        </a-tab-pane>
      </a-tabs>

      <div class="fieldset">
        <table>
          <tbody>
            <tr>
              <td></td>
              <td align="center">秒</td>
              <td align="center">分钟</td>
              <td align="center">小时</td>
              <td align="center">日</td>
              <td align="center">月<br /> </td>
              <td align="center">星期</td>
              <td align="center">年</td>
            </tr>
            <tr>
              <td>表达式字段:</td>
              <td><a-input type="text" name="v_second" class="col" :value="secondsText() || '*'" readonly="readonly" size="small" /></td>
              <td><a-input type="text" name="v_min" class="col" :value="minutesText() || '*'" readonly="readonly" size="small" /></td>
              <td><a-input type="text" name="v_hour" class="col" :value="hoursText() || '*'" readonly="readonly" size="small" /></td>
              <td><a-input type="text" name="v_day" class="col" :value="daysText() || '*'" readonly="readonly" size="small" /></td>
              <td><a-input type="text" name="v_mouth" class="col" :value="monthsText() || '*'" readonly="readonly" size="small" /></td>
              <td><a-input type="text" name="v_week" class="col" :value="weeksText() || '?'" readonly="readonly" size="small" /></td>
              <td><a-input type="text" name="v_year" class="col" :value="yearsText()" readonly="readonly" size="small" /></td>
            </tr>
            <tr>
              <td>Cron 表达式:</td>
              <td colspan="6">
                <p class="cronName">{{ cron }}</p>
              </td>
            </tr>
            <!-- <tr>
              <td colspan="8">最近5次运行时间:</td>
            </tr>
            <tr>
              <td colspan="8">
                <span v-for="(item, index) in recentTime" :key="index" class="time">{{ item }}</span>
              </td>
            </tr> -->
          </tbody>
        </table>
      </div>
    </section>
  </BasicModal>
</template>

<script setup>
  import { BasicModal } from '/@/components/Modal';
  import { recent5TriggerTime } from '../design.api';
  import { ref, watchEffect, computed } from 'vue';
  const visible = ref(false);
  const emit = defineEmits(['ok']);
  const props = defineProps({
    data: { type: String },
  });
  const confirmLoading = ref(false);
  const result = ref({
    second: {},
    minute: {},
    hour: {},
    day: {},
    week: {},
    month: {},
    year: {},
  });
  // const recentTime = ref([]);
  const activeKey = ref('1');
  const defaultValue = {
    second: {
      cronEvery: '1',
      incrementStart: 0,
      incrementIncrement: 1,
      rangeStart: 1,
      rangeEnd: 2,
      specificSpecific: [],
    },
    minute: {
      cronEvery: '1',
      incrementStart: 0,
      incrementIncrement: 1,
      rangeStart: 1,
      rangeEnd: 2,
      specificSpecific: [],
    },
    hour: {
      cronEvery: '1',
      incrementStart: 0,
      incrementIncrement: 1,
      rangeStart: 0,
      rangeEnd: 2,
      specificSpecific: [],
    },
    day: {
      cronEvery: '1',
      incrementStart: 1,
      incrementIncrement: 1,
      rangeStart: 1,
      rangeEnd: 2,
      specificSpecific: [],
      cronDaysNearestWeekday: 1,
      cronLastSpecificDomDay: 1,
    },
    month: {
      cronEvery: '1',
      incrementStart: 1,
      incrementIncrement: 1,
      rangeStart: 1,
      rangeEnd: 2,
      specificSpecific: [],
    },
    week: {
      cronEvery: '1',
      incrementStart: 1,
      incrementIncrement: 2,
      specificSpecific: [],
      cronNthDayDay: 1,
      cronNthDayNth: 1,
      lastweekDy: 1,
    },
    year: {
      cronEvery: '',
      rangeStart: 2013,
      rangeEnd: 2014,
      specificSpecific: [],
    },
  };
  function show() {
    visible.value = true;
  }
  watchEffect(() => {
    if (visible.value) {
      let label = props.data;
      if (label) {
        secondsReverseExp(label);
        minutesReverseExp(label);
        hoursReverseExp(label);
        daysReverseExp(label);
        weeksReverseExp(label);
        monthsReverseExp(label);
        yearReverseExp(label);
        // handleChange();
      } else {
        result.value = JSON.parse(JSON.stringify(defaultValue));
      }
    }
  });
  const cron = computed(() => {
    return `${secondsText() || '*'} ${minutesText() || '*'} ${hoursText() || '*'} ${daysText() || '*'} ${monthsText() || '*'} ${
      weeksText() || '?'
    } ${yearsText()}`;
  });
  function closeDetail() {
    visible.value = false;
    activeKey.value = '1';
  }
  function handleOk() {
    emit('ok', cron._value);
    closeDetail();
  }
  function secondsText() {
    let seconds = '';
    let cronEvery = result.value.second.cronEvery || '';
    switch (cronEvery.toString()) {
      case '1':
        seconds = '*';
        break;
      case '2':
        seconds = result.value.second.incrementStart + '/' + result.value.second.incrementIncrement;
        break;
      case '3':
        result.value.second.specificSpecific.map((val) => {
          seconds += val + ',';
        });
        seconds = seconds.slice(0, -1);
        break;
      case '4':
        seconds = result.value.second.rangeStart + '-' + result.value.second.rangeEnd;
        break;
    }
    return seconds;
  }
  function minutesText() {
    let minutes = '';
    let cronEvery = result.value.minute.cronEvery || '';
    switch (cronEvery.toString()) {
      case '1':
        minutes = '*';
        break;
      case '2':
        minutes = result.value.minute.incrementStart + '/' + result.value.minute.incrementIncrement;
        break;
      case '3':
        result.value.minute.specificSpecific.map((val) => {
          minutes += val + ',';
        });
        minutes = minutes.slice(0, -1);
        break;
      case '4':
        minutes = result.value.minute.rangeStart + '-' + result.value.minute.rangeEnd;
        break;
    }
    return minutes;
  }
  function hoursText() {
    let hours = '';
    let cronEvery = result.value.hour.cronEvery || '';
    switch (cronEvery.toString()) {
      case '1':
        hours = '*';
        break;
      case '2':
        hours = result.value.hour.incrementStart + '/' + result.value.hour.incrementIncrement;
        break;
      case '3':
        result.value.hour.specificSpecific.map((val) => {
          hours += val + ',';
        });
        hours = hours.slice(0, -1);
        break;
      case '4':
        hours = result.value.hour.rangeStart + '-' + result.value.hour.rangeEnd;
        break;
    }
    return hours;
  }
  function daysText() {
    let days = '';
    let cronEvery = result.value.day.cronEvery || '';
    switch (cronEvery.toString()) {
      case '1':
        break;
      case '2':
        days = '?';
        break;
      case '3':
        days = result.value.day.incrementStart + '/' + result.value.day.incrementIncrement;
        break;
      case '4':
        days = result.value.day.rangeStart + '-' + result.value.day.rangeEnd;
        break;
      case '5':
        result.value.day.specificSpecific.map((val) => {
          days += val + ',';
        });
        days = days.slice(0, -1);
        break;
      case '6':
        days = 'L';
        break;
      case '7':
        days = result.value.day.cronDaysNearestWeekday + 'W';
    }
    return days;
  }
  function weeksText() {
    let weeks = '';
    let cronEvery = result.value.week.cronEvery || '';
    switch (cronEvery.toString()) {
      case '1':
        weeks = '*';
        break;
      case '2':
        weeks = result.value.week.incrementStart + '/' + result.value.week.incrementIncrement;
        break;
      case '3':
        weeks = result.value.week.cronNthDayDay + '#' + result.value.week.cronNthDayNth;
        break;
      case '4':
        result.value.week.specificSpecific.map((val) => {
          weeks += val + ',';
        });
        weeks = weeks.slice(0, -1);
        break;
      case '5':
        weeks = '?';
        break;
      case '6':
        weeks = result.value.week.lastweekDy + 'L';
        break;
    }
    return weeks;
  }
  function monthsText() {
    let months = '';
    let cronEvery = result.value.month.cronEvery || '';
    switch (cronEvery.toString()) {
      case '1':
        months = '*';
        break;
      case '2':
        months = result.value.month.incrementStart + '/' + result.value.month.incrementIncrement;
        break;
      case '3':
        result.value.month.specificSpecific.map((val) => {
          months += val + ',';
        });
        months = months.slice(0, -1);
        break;
      case '4':
        months = result.value.month.rangeStart + '-' + result.value.month.rangeEnd;
        break;
      case '5':
        months = '?';
        break;
    }
    return months;
  }
  function yearsText() {
    let years = '';
    let cronEvery = result.value.year.cronEvery || '';
    switch (cronEvery.toString()) {
      case '1':
        years = '*';
        break;
      case '2':
        years = result.value.year.incrementStart + '/' + result.value.year.incrementIncrement;
        break;
      case '3':
        result.value.year.specificSpecific.map((val) => {
          years += val + ',';
        });
        years = years.slice(0, -1);
        break;
      case '4':
        years = result.value.year.rangeStart + '-' + result.value.year.rangeEnd;
        break;
      case '5':
        years = '';
        break;
    }
    return years;
  }
  function secondsReverseExp(seconds) {
    let val = seconds.split(' ')[0];
    let exp = /^[+-]?\d*(\.\d*)?(e[+-]?\d+)?$/;
    let second = {
      cronEvery: '',
      incrementStart: 0,
      incrementIncrement: 1,
      rangeStart: 1,
      rangeEnd: 2,
      specificSpecific: [],
    };
    switch (true) {
      case val.includes('*'):
        second.cronEvery = '1';
        break;
      case val.includes('/'):
        second.cronEvery = '2';
        second.incrementStart = val.split('/')[0];
        second.incrementIncrement = val.split('/')[1];
        break;
      case val.includes(','):
      case exp.test(val):
        second.cronEvery = '3';
        second.specificSpecific = val.split(',').map(Number).sort();
        break;
      case val.includes('-'):
        second.cronEvery = '4';
        second.rangeStart = val.split('-')[0];
        second.rangeEnd = val.split('-')[1];
        break;
    }
    result.value.second = second;
  }
  function minutesReverseExp(minutes) {
    let val = minutes.split(' ')[1];
    let exp = /^[+-]?\d*(\.\d*)?(e[+-]?\d+)?$/;
    let minute = {
      cronEvery: '',
      incrementStart: 0,
      incrementIncrement: 1,
      rangeStart: 1,
      rangeEnd: 2,
      specificSpecific: [],
    };
    switch (true) {
      case val.includes('*'):
        minute.cronEvery = '1';
        break;
      case val.includes('/'):
        minute.cronEvery = '2';
        minute.incrementStart = val.split('/')[0];
        minute.incrementIncrement = val.split('/')[1];
        break;
      case val.includes(','):
      case exp.test(val):
        minute.cronEvery = '3';
        minute.specificSpecific = val.split(',').map(Number).sort();
        break;
      case val.includes('-'):
        minute.cronEvery = '4';
        minute.rangeStart = val.split('-')[0];
        minute.rangeEnd = val.split('-')[1];
        break;
    }
    result.value.minute = minute;
  }
  function hoursReverseExp(hours) {
    let val = hours.split(' ')[2];
    let exp = /^[+-]?\d*(\.\d*)?(e[+-]?\d+)?$/;
    let hour = {
      cronEvery: '',
      incrementStart: 0,
      incrementIncrement: 1,
      rangeStart: 0,
      rangeEnd: 2,
      specificSpecific: [],
    };
    switch (true) {
      case val.includes('*'):
        hour.cronEvery = '1';
        break;
      case val.includes('/'):
        hour.cronEvery = '2';
        hour.incrementStart = val.split('/')[0];
        hour.incrementIncrement = val.split('/')[1];
        break;
      case val.includes(','):
      case exp.test(val):
        hour.cronEvery = '3';
        hour.specificSpecific = val.split(',').map(Number).sort();
        break;
      case val.includes('-'):
        hour.cronEvery = '4';
        hour.rangeStart = val.split('-')[0];
        hour.rangeEnd = val.split('-')[1];
        break;
    }
    result.value.hour = hour;
  }
  function daysReverseExp(cron) {
    let days = cron.split(' ')[3];
    let exp = /^[+-]?\d*(\.\d*)?(e[+-]?\d+)?$/;
    let day = {
      cronEvery: '',
      incrementStart: 1,
      incrementIncrement: 1,
      rangeStart: 1,
      rangeEnd: 2,
      specificSpecific: [],
      cronDaysNearestWeekday: 1,
      cronLastSpecificDomDay: 1,
    };
    if (!days.includes('?')) {
      switch (true) {
        case days.includes('*'):
          day.cronEvery = '1';
          break;
        case days.includes('?'):
        case exp.test(days):
          day.cronEvery = '2';
          break;
        case days.includes('/'):
          day.cronEvery = '3';
          day.incrementStart = days.split('/')[0];
          day.incrementIncrement = days.split('/')[1];
          break;
        case days.includes('-'):
          day.cronEvery = '4';
          day.rangeStart = days.split('-')[0];
          day.rangeEnd = days.split('-')[1];
          break;
        case days.includes(','):
          day.cronEvery = '5';
          day.specificSpecific = days.split(',').map(Number).sort();
          // day.specificSpecific.forEach(function (value, index) {
          //   day.specificSpecific[index] = value -1;
          // });
          break;
        case 'L':
          day.cronEvery = '6';
          day.cronLastSpecificDomDay = '1';
          break;
        case days.includes('W'):
          day.cronEvery = '7';
          day.cronDaysNearestWeekday = days.split('W')[0];
          break;
      }
    }
    result.value.day = day;
  }
  function weeksReverseExp(cron) {
    let weeks = cron.split(' ')[5];
    let exp = /^[+-]?\d*(\.\d*)?(e[+-]?\d+)?$/;
    let week = {
      cronEvery: '',
      incrementStart: 1,
      incrementIncrement: 2,
      specificSpecific: [],
      cronNthDayDay: 1,
      cronNthDayNth: 1,
      lastweekDy: 1,
    };
    switch (true) {
      case weeks.includes('/'):
        week.cronEvery = '2';
        week.incrementStart = weeks.split('/')[0];
        week.incrementIncrement = weeks.split('/')[1];
        break;
      case weeks.includes(','):
        week.cronEvery = '4';
        week.specificSpecific = weeks.split(',').map(Number).sort();
        break;
      case weeks.includes('#'):
        week.cronEvery = '3';
        week.cronNthDayDay = weeks.split('#')[0];
        week.cronNthDayNth = weeks.split('#')[1];
        break;
      case weeks.includes('?'):
      case exp.test(weeks):
        week.cronEvery = '5';
        break;
      case weeks.includes('L'):
        week.cronEvery = '6';
    }
    result.value.week = week;
    console.log(result.value.week);
  }
  function monthsReverseExp(cron) {
    let months = cron.split(' ')[4];
    let exp = /^[+-]?\d*(\.\d*)?(e[+-]?\d+)?$/;
    let month = {
      cronEvery: '',
      incrementStart: 1,
      incrementIncrement: 1,
      rangeStart: 1,
      rangeEnd: 2,
      specificSpecific: [],
    };
    switch (true) {
      case months.includes('*'):
        month.cronEvery = '1';
        break;
      case months.includes('/'):
        month.cronEvery = '2';
        month.incrementStart = months.split('/')[0];
        month.incrementIncrement = months.split('/')[1];
        break;
      case months.includes(','):
      case exp.test(months):
        month.cronEvery = '3';
        month.specificSpecific = months.split(',').map(Number).sort();
        break;
      case months.includes('-'):
        month.cronEvery = '4';
        month.rangeStart = months.split('-')[0];
        month.rangeEnd = months.split('-')[1];
        break;
      case months.includes('?'):
        month.cronEvery = '5';
        break;
    }
    result.value.month = month;
  }
  function yearReverseExp(cron) {
    let years = cron.split(' ')[6];
    let year = {
      cronEvery: '',
      rangeStart: 2013,
      rangeEnd: 2014,
      specificSpecific: [],
    };
    switch (true) {
      case years == undefined:
        break;
      case years.includes('*'):
        year.cronEvery = '1';
        break;
      case years.includes('/'):
        year.cronEvery = '2';
        year.incrementStart = years.split('/')[0];
        year.incrementIncrement = years.split('/')[1];
        break;
      case years.includes(','):
        year.cronEvery = '3';
        year.specificSpecific = years.split(',').map(Number).sort();
        break;
      case years.includes('-'):
        year.cronEvery = '4';
        year.rangeStart = years.split('-')[0];
        year.rangeEnd = years.split('-')[1];
        break;
    }
    result.value.year = year;
  }
  function handleChange() {
    // let crons = cron._value;
    // recent5TriggerTime({ cron: crons }).then((res) => {
    //   recentTime.value = res;
    // });
  }
  defineExpose({
    show,
  });
</script>
<style lang="less" scoped>
  .container-widthEn {
    width: 755px;
  }
  .container-widthCn {
    width: 608px;
  }
  .language {
    text-align: center;
    position: absolute;
    right: 13px;
    top: 13px;
    border: 1px solid transparent;
    height: 40px;
    line-height: 38px;
    font-size: 16px;
    color: #409eff;
    z-index: 1;
    background: #f5f7fa;
    outline: none;
    width: 47px;
    border-bottom: 1px solid #e6ebf5;
    border-radius: 0;
  }
  .card-container {
    .ant-row {
      margin: 10px 0;
    }
    .bottom {
      display: flex;
      justify-content: center;
      padding: 10px 0 0 0;
      .cronButton {
        margin: 0 10px;
        line-height: 40px;
      }
    }
  }
  .tabBody {
    .a-row {
      margin: 10px 0;
      .long {
        .a-select {
          width: 354px;
        }
      }
      .a-input-number {
        width: 110px;
      }
    }
  }

  .fieldset {
    border-radius: 3px;
    height: 150px;
    border: solid 1px #eee;
    padding: 10px 0;

    table {
      font-size: 12px;
      .col {
        width: 100px !important;
      }
      .cronName {
        width: 100%;
        height: 24px;
        line-height: 24px;
        border: solid 1px #d9d9d9;
        padding: 0 7px;
      }
      .time {
        margin-right: 50px;
      }
    }
  }
</style>
